!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define("rb_wixui.thunderbolt[TextInput]",["react"],t):"object"==typeof exports?exports["rb_wixui.thunderbolt[TextInput]"]=t(require("react")):e["rb_wixui.thunderbolt[TextInput]"]=t(e.React)}("undefined"!=typeof self?self:this,function(e){return function(){var t={"Xdf/":function(t){"use strict";t.exports=e},Fe5V:function(e){function t(){return e.exports=t=Object.assign?Object.assign.bind():function(e){for(var t=1;t{const n=[];return e&&n.push(`${l}${e}`),t.forEach(e=>{e&&(n.push(`${l}${e}`),n.push(e))}),n.join(" ")},s=13,d=27;function c(e){return t=>{t.keyCode===e&&(t.preventDefault(),t.stopPropagation(),t.currentTarget.click())}}c(32),c(s),c(d);const p=["aria-id","aria-metadata","aria-type"],f=(e,t)=>Object.entries(e).reduce((e,[n,r])=>(t.includes(n)||(e[n]=r),e),{}),m=e=>{const{role:t,tabIndex:n,tabindex:r,screenReader:o,lang:a,ariaAttributes:i={}}=e,l=Object.entries(i).reduce((e,[t,n])=>({...e,[`aria-${t}`.toLowerCase()]:n}),{});return{role:t,tabIndex:n??r,screenReader:o,ariaAttributes:f(l,p),lang:a}};const h=({size:e,...t})=>n.createElement("svg",{viewBox:"0 0 20 20",fill:"currentColor",width:e||"20",height:e||"20",...t},n.createElement("path",{fillRule:"evenodd",d:"M9.5,3 C13.084,3 16,5.916 16,9.5 C16,13.084 13.084,16 9.5,16 C5.916,16 3,13.084 3,9.5 C3,5.916 5.916,3 9.5,3 Z M9.5,4 C6.467,4 4,6.467 4,9.5 C4,12.533 6.467,15 9.5,15 C12.533,15 15,12.533 15,9.5 C15,6.467 12.533,4 9.5,4 Z M10,11 L10,12 L9,12 L9,11 L10,11 Z M10,7 L10,10 L9,10 L9,7 L10,7 Z"}));h.displayName="ErrorSmall";var v=h,g="wBdYEC",y="cfVDAB",b="YCipIB";const x=e=>{let{errorMessage:t,errorMessageType:r,shouldShowValidityIndication:o,translations:a,dataHook:i,componentViewMode:l}=e;const u="editor"===l?(null==a?void 0:a.errorMessage)||"Error text displays here.":t;return"inline"===r&&o&&u?n.createElement("div",{"data-hook":i||"inline-error-message",className:g},n.createElement(v,{className:y}),n.createElement("span",{className:b},u)):null};var C={root:"text-input",inputEl:"text-input__input",inputLabel:"text-input__label"},E={input:"KvoMHf",hideNumberSpinner:"ErucfC",AppsTextInputSkin:"MpKiNN",appsTextInputSkin:"MpKiNN",inputWrapper:"pUnTVX",prefix:"eXvLsN","validation-indication":"LyB02C",validationIndication:"LyB02C",label:"wPeA6j",hasLabel:"qzvPmW","required-indication":"lPl_oN",requiredIndication:"lPl_oN",ResponsiveTextInputSkin:"ZXdXNL",responsiveTextInputSkin:"ZXdXNL"};const I="Please enter a phone number with {digits} digits",M="Please enter between 4 to 17 digits. You can include hyphens (-) or start with a (+), e.g., 555-123-4567 or +(222)987654321",_="Please enter between 4 to 17 digits. You can include dividers (-), e.g., 555-123-4567.",L=function(e,t,n){void 0===n&&(n=!0);return Array.from(t).reduce((e,t,n)=>"-"===t?[...e,n]:e,[]).filter((t,r)=>n?t<=e.length:t<=e.length+r)},O=(e,t)=>t.replace("{digits}",""+(e?e.replace(/-/g,"").length:0)),N=()=>{},V=(e,r)=>{var o,a;const{skin:l,name:s,id:d,className:c="",customClassNames:p=[],dataTestId:f,value:h,inputType:v="text",label:g,placeholder:y,readOnly:b,required:V,isDisabled:w,pattern:A,autoComplete:T,autoComplete_:P,maxLength:F,min:R,max:S,step:j,numberSpinnerHidden:k,shouldShowValidityIndication:H,autoFocus:D,prefix:q,phoneFormat:X="",errorMessageType:B="tooltip",validateValue:Z=N,setValidityIndication:$=N,onBlur:K=N,onFocus:U=N,onKeyPress:W=N,onInput:Y=N,onValueChange:z=N,onChange:G=N,onClick:J=N,onDblClick:Q=N,onMouseEnter:ee=N,onMouseLeave:te=N,onHydrationComplete:ne=N,ariaAttributes:re,contentRef:oe,translations:ae,componentViewMode:ie,textInputAutoFillFixEnabled:le,lang:ue}=e,se=n.useRef(null);n.useImperativeHandle(r,()=>({focus:()=>{var e;null==(e=se.current)||e.focus()},blur:()=>{var e;null==(e=se.current)||e.blur()},setCustomValidity:t=>{var n,r;"message"===t.type?null==(n=se.current)||n.setCustomValidity(t.message):null==(r=se.current)||r.setCustomValidity(((e,t)=>{let{translations:n,phoneFormat:r}=t;switch(e.key){case"PHONE_FORMAT_LENGTH_VALIDATION_ERROR":return O(r,(null==n?void 0:n.phoneFormatLengthValidationError)||I);case"PHONE_FORMAT_DEFAULT_VALIDATION_ERROR":return(null==n?void 0:n.phoneFormatDefaultValidationError)||M;case"PHONE_FORMAT_COMPLEX_PHONE_DEFAULT_VALIDATION_ERROR":return(null==n?void 0:n.phoneFormatComplexPhoneDefaultValidationError)||_;default:return e.key}})(t,{translations:e.translations,phoneFormat:e.phoneFormat}))},getValidationMessage:()=>{var e;return null==(e=se.current)?void 0:e.validationMessage}}));const de=n.useRef(),ce=n.useMemo(()=>"tel"===v&&X?((e,t)=>{const n=L(e,t,!1),r=Array.from(e);return n.forEach(e=>{e{let{shouldHideValidityIndication:t,shouldCallOnInput:n}=e;return e=>{const{value:r}=e.target;let o=r;if(X){const e=r.length{const r=L(e,t);return r.reduce((t,o,a)=>{if(" "===e[o])t.splice(o-a,1);else if(" "!==e[o+1]||n)" "===e[o-1]&&n&&(e.split(" ").length-1{le&&!ve()&&G({...e,type:"change"})})(e),Z()),t&&$(!1),n&&Y(e)}};n.useEffect(()=>{var e,t;pe({shouldHideValidityIndication:!0,shouldCallOnInput:!1})({target:{value:null!=(e=null==(t=se.current)?void 0:t.value)?e:""}}),ne({type:"onHydrationComplete"})},[]);const fe=i(E[l],c,u(C.root,...p),{[E.hasLabel]:!!g,[E.requiredIndication]:V,[E.validationIndication]:!!H}),{ariaAttributes:{"aria-label":me,...he}}=m({ariaAttributes:re}),ve=()=>!!se.current&&se.current===document.activeElement,ge=!(null==(o=se.current)||!o.validationMessage)&&H;return n.createElement("div",t()({id:d},(e=>Object.entries(e).reduce((e,[t,n])=>(t.includes("data-")&&(e[t]=n),e),{}))(e),{ref:oe,className:fe,"data-testid":f,onClick:e=>{w||J(e)},onDoubleClick:e=>{w||Q(e)},onMouseEnter:e=>{w||ee(e)},onMouseLeave:e=>{w||te(e)},lang:ue}),!!g&&n.createElement("label",{htmlFor:"input_"+d,className:i(E.label,u(C.inputLabel))},g),n.createElement("div",{className:E.inputWrapper},q&&n.createElement("div",{className:E.prefix},q),n.createElement("input",t()({name:s,ref:se,id:"input_"+d,className:i(E.input,"has-custom-focus",u(C.inputEl),{[E.hideNumberSpinner]:k}),type:v,value:ce,onFocus:U,onKeyDown:W,onChange:pe({shouldHideValidityIndication:!0,shouldCallOnInput:!0}),onBlur:e=>{K(e),de.current&&G({...e,type:"change"}),de.current=!1,$(!0)},placeholder:y,readOnly:b,required:V,"aria-invalid":ge,pattern:A,maxLength:(()=>{let e=null===F?void 0:F;return X&&(e=X.length),e})(),minLength:X?X.length:void 0,disabled:w,autoComplete:T?"on":P||"off",step:null===j?void 0:j,min:null===R?void 0:R,max:null===S?void 0:S,autoFocus:D},me&&{"aria-label":me},!V&&{"aria-required":!1},he))),n.createElement(x,{errorMessageType:B,errorMessage:null==(a=se.current)?void 0:a.validationMessage,shouldShowValidityIndication:H,translations:ae,componentViewMode:ie}))};const w=e=>e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`);var A;const T={TextInput:{component:n.forwardRef(V),controller:(A=e=>{let{mapperProps:t,controllerUtils:n}=e;return{...t,...(r=n.updateProps,{onValueChange:e=>{r({value:e})},setValidityIndication:e=>{r({shouldShowValidityIndication:e})}})};var r},{useComponentProps:(e,t,n)=>{const r=(e=>({...e,updateStyles:t=>{const n=Object.entries(t).reduce((e,[t,n])=>{return{...e,[(r=t,r.startsWith("--")?t:w(t))]:void 0===n?null:n};var r},{});e.updateStyles(n)}}))(n);return A({mapperProps:e,stateValues:t,controllerUtils:r})}})}}}(),o}()}); //# sourceMappingURL=https://static.parastorage.com/services/editor-elements-library/dist/thunderbolt/rb_wixui.thunderbolt[TextInput].35b7f2b7.bundle.min.js.map